#!/usr/bin/python
#encoding=utf-8
'''
Created on May 16, 2014

@author: root
'''
import os
import stat
import filecmp 


def compare_file(local_image,tmp_image):
    out = False
    try:
        det_result = filecmp.cmp(local_image,tmp_image) 
        if det_result:
            os.chmod(tmp_image, stat.S_IRUSR + stat.S_IWRITE + stat.S_IXUSR)
            os.remove(tmp_image)
        else:
            out = True
        return out
    except:
        print 'No such file (%s,%s)'%(local_image,tmp_image)
        return out
    
if __name__=='__main__':
    f1 = '/var/qgtamper/qzlxmhw.jpg'
    f2 = '/var/qgtamper/tmp/qzlxmhw.jpg'
    compare_file(f1,f2)
